Imports CapaDeNegocios
Partial Public Class FrmMarcaABM
    Inherits System.Web.UI.Page
    Private TblMarca As nMarca = New CapaDeNegocios.nMarca()
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            If Session("Login") = "Anonimo" Then
                Response.Redirect("/")
            End If
            LLenar_Grid()
        End If
    End Sub
    Sub LLenar_Grid()
        GVMarca.DataSource = TblMarca.Listar()
        GVMarca.DataBind()
        LimpiarCampos()
    End Sub
    Sub LimpiarCampos()

        TxtDescripcion.Text = ""
    End Sub

    Protected Sub LnkGuardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LnkGuardar.Click
       
        If TxtDescripcion.Text <> "" Then
            TblMarca.Insertar(TxtDescripcion.Text)
        End If
        TblMarca.Modificar(HFMarca.Value, TxtDescripcion.Text)
        LLenar_Grid()
    End Sub


    Protected Sub LnkEliminar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LnkEliminar.Click

        TblMarca.Eliminar(HFMarca.Value)
    End Sub


    Protected Sub LnkBuscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LnkBuscar.Click
        
        GVMarca.DataSource = TblMarca.Buscar(HFMarca.Value, TxtDescripcion.Text)
        GVMarca.DataBind()

    End Sub

    Protected Sub GVTipoUnidad_RowCommand(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GVMarca.RowCommand
      

        If e.CommandName = "Select" Then
            HFMarca.Value = e.CommandSource.Parent.FindControl("HFcodigoMarca").value
            TxtDescripcion.Text = e.CommandSource.Parent.Parent.FindControl("lblDescripcion").text

        End If
    End Sub

    Protected Sub LnkCancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnkcancelar.Click
        LLenar_Grid()
    End Sub





End Class